package chai.ning.polym;

public class Triangle extends Shape {
	
	private int first ;
	private int second ;
	private int third ;

	public Triangle() {
		super( "三角形" );
	}
	
	public Triangle(int first, int second, int third) {
		super( "三角形" );
		this.first = first;
		this.second = second;
		this.third = third;
	}

	@Override
	public void calculate() {
		boolean x = check() ;
		if( x ) {
			double p = ( first + second + third ) / 2.0 ;
			double y = p * ( p - first ) * ( p - second ) * ( p - third );
			// 求面积
			this.area = Math.sqrt( y ); // 开平方
		}
	}
	
	private boolean check() {
		// 在这里检查三条边是否可以构成三角形
		return true ;
	}
	
}
